﻿using System.Collections.Generic;

namespace Engine.AI.Astar
{
    public abstract class State
    {
        public abstract float Weight { get; }
        public abstract List<State> GenerateChilds(HashSet<State> visitedPoints);
        public abstract void ComputeWeight();        
        public abstract bool IsGoal(State state);

        public State Parent { get; set; }
     
        protected int _height = -1;
        
        private float _maxError = 1;
        public float MaxError
        {
            get { return _maxError; }
            set { _maxError = value; }
        }
        public int Height
        {
            get
            {
                if (_height == -1)
                {
                    State parent = Parent;
                    int height = 0;

                    while (parent != null)
                    {
                        height++;
                        parent = parent.Parent;
                    }
                    _height = height;
                }
                return _height;
            }
        }
    }
}
